<?xml version="1.0" encoding="utf-8"?>
<Window
    x:Class="Automator.Windows.OpenWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Open Document"
    Height="500"
    Width="400"
    MinWidth="250"
    MinHeight="300"
    WindowStartupLocation="CenterOwner"
    ShowInTaskbar="False"
    ShowActivated="True"
    Background="{x:Static SystemColors.ControlBrush}"
    Loaded="Window_Loaded">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition
                Height="Auto" />
            <RowDefinition
                Height="Auto" />
            <RowDefinition
                Height="Auto" />
            <RowDefinition
                Height="*" />
            <RowDefinition
                Height="Auto" />
            <RowDefinition
                Height="Auto" />
        </Grid.RowDefinitions>
        <RadioButton
            Content="Open From File System"
            IsChecked="True"
            Grid.Row="0"
            Margin="8"
            x:Name="rbFileSystem"
            Click="RbFileSystem_Click"
            TabIndex="0" />
        <DockPanel
            LastChildFill="True"
            Grid.Row="1">
            <Button
                x:Name="btnOpen"
                DockPanel.Dock="Right"
                Margin="0,4,4,4"
                ToolTip="Choose file"
                Click="BtnOpen_Click"
                Padding="4,1,4,1">
                <Image
                    Source="/Automator;component/resources/open.png"
                    Width="16"
                    Height="16" />
            </Button>
            <TextBox
                x:Name="edtFileName"
                Margin="4"
                VerticalContentAlignment="Center" />
        </DockPanel>
        <RadioButton
            Content="Open From SQL Server"
            IsChecked="False"
            Grid.Row="2"
            Margin="8"
            x:Name="rbDatabase"
            Click="RbFileSystem_Click"
            TabIndex="0" />
        <ListView
            Grid.Row="3"
            x:Name="gridEntities"
            IsSynchronizedWithCurrentItem="True"
            MouseDoubleClick="GridEntities_MouseDoubleClick">
            <ListView.View>
                <GridView>
                    <GridViewColumn Width="40">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Button
                                    HorizontalAlignment="Center"
                                    ToolTip="Delete document"
                                    Margin="2"
                                    x:Name="btnDeleteDocument"
                                    Click="BtnDeleteDocument_Click"
                                    Tag="{Binding Path=Id}">
                                    <Button.Style>
                                        <Style TargetType="{x:Type Button}">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Path=Visible}" Value="0">
                                                    <Setter Property="Visibility" Value="Hidden" />
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Button.Style>
                                    <Image
                                        Source="/Automator;component/Resources/delete.png"
                                        Width="16"
                                        Height="16" />
                                </Button>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn
                        Header="Document Name"
                        Width="320">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock
                                    Margin="8"
                                    TextWrapping="Wrap"
                                    TextTrimming="CharacterEllipsis"
                                    Text="{Binding Path=Name}" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
        <DockPanel
            LastChildFill="True"
            Grid.Row="4">
            <TextBlock
                DockPanel.Dock="Left"
                Text="Filter:"
                VerticalAlignment="Center"
                Margin="8" />
            <TextBox
                Margin="2"
                x:Name="edtFilter"
                VerticalAlignment="Stretch"
                VerticalContentAlignment="Center"
                TextChanged="EdtFilter_TextChanged" />
        </DockPanel>
        <StackPanel
            Orientation="Horizontal"
            Grid.Row="5"
            HorizontalAlignment="Right">
            <Button
                Name="btnOk"
                Content="OK"
                Padding="16,4,16,4"
                Click="BtnOk_Click"
                Margin="4" />
            <Button
                Name="btnCancel"
                Content="Cancel"
                Padding="16,4,16,4"
                Margin="4"
                IsCancel="True" />
        </StackPanel>
    </Grid>
</Window>